<template>
    <el-row type="flex" class="row-bg" justify="space-between">
        <el-col :xs="24" :sm="12" :lg="8" :xl="8">
            <el-form :model="form" label-width="120px">
                <el-form-item label="网站名称">
                    <el-input v-model="form['website.name']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="备案号">
                    <el-input v-model="form['website.icp']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="网站标题">
                    <el-input v-model="form['website.title']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="网站关键字">
                    <el-input type="textarea" :rows="2" v-model="form['website.keywords']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="网站描述">
                    <el-input type="textarea" :rows="5" v-model="form['website.description']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="站长邮箱">
                    <el-input v-model="form['website.admin_mail']" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="update" :loading="loading">更新</el-button>
                    <el-button @click="$router.go(-1)">返回</el-button>
                </el-form-item>
            </el-form>
        </el-col>
    </el-row>

</template>

<script>
    export default {
        name: "setting-index",
        data () {
            return {
                loading: false,
                form: {}
            };
        },
        computed: {
            configs() {
                return this.$store.getters['config/all'];
            }
        },
        watch: {
            configs() {
                this.form = Object.assign({}, this.configs);
            }
        },
        methods: {
            update() {
                this.loading = true;
                this.$store.dispatch('config/Update', {configs: this.form}).then(res => {
                    this.$message.success(res.data.message);
                }).finally(() => {
                    this.loading = false;
                });
            }
        },
        created() {
            if (this.configs) this.form = Object.assign({}, this.configs);
            //console.log(this.configs)
        }
    }
</script>

<style scoped>

</style>
